public class stringTest2 {
    public static void main(String[] args) {

        //字符串拼接
        int[] arr={1,2,3};

        String str= arrToString(arr);
        System.out.println(str);

        //字符串反转
        String res=reverser("abc");
        System.out.println(res);
    }

    public  static  String arrToString(int[] arr){
        if(arr==null){
            return "";
        }
        if(arr.length==0){
            return"[]";
        }

        String result="[";
        //数组：length
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                result=result+arr[i];
            }else {
                result=result+arr[i]+",";
            }
        }

        result=result+"]";
        return  result;
    }

    public static String reverser(String str){
        String res="";
        //string：length()
        for(int i=str.length()-1;i>=0;i--){
            char c=str.charAt(i);
            res=res+c;
        }
        return res;
    }

}
